<template>
  <view class="my-page">
    <!-- 顶部信息区域 -->
    <view class="top-bar">
      <image class="avatar" :src="avatar" mode="aspectFill"></image>
      <view class="user-info">
        <text class="username">{{username}}</text>
        <text class="user-id">ID: {{userId}}</text>
        <text class="member-tag" v-if="isMember">{{memberTag}}</text>
      </view>
      <image class="msg-icon" :src="msgIcon" mode="aspectFill"></image>
    </view>

    <!-- VIP 开通提示区域 -->
    <view class="vip-box">
      <text class="vip-title"><text class="vip-icon">★</text> VIP</text>
      <text class="vip-desc">开通会员享优惠特权</text>
      <button class="open-vip-btn" @click="openVip">立即开通</button>
    </view>

    <!-- 功能菜单区域 -->
    <view class="menu-list">
      <view class="menu-item" v-for="(item, index) in menuList" :key="index" @click="handleMenuClick(item)">
        <image class="menu-icon" :src="item.icon" mode="aspectFill"></image>
        <text class="menu-text">{{item.text}}</text>
      </view>
    </view>

    <!-- 底部 tabbar（uniapp 可结合官方 tabbar 配置，这里简单模拟示意） -->
    <view class="tabbar">
      <view class="tabbar-item" v-for="(tab, tabIndex) in tabbarList" :key="tabIndex" @click="switchTab(tab)">
        <image class="tab-icon" :src="tab.icon" mode="aspectFill"></image>
        <text class="tab-text">{{tab.text}}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 用户信息
      avatar: 'https://example.com/avatar.png', // 实际替换为用户头像地址
      username: '寂寞天使',
      userId: '5698231',
      isMember: true,
      memberTag: '月卡会员',
      msgIcon: 'https://example.com/msg-icon.png', // 消息图标地址

      // VIP 相关
      vipIcon: 'https://example.com/vip-icon.png',

      // 功能菜单数据
      menuList: [
        { icon: 'https://example.com/icon1.png', text: '个人资料' },
        { icon: 'https://example.com/icon2.png', text: '邀约订单' },
        { icon: 'https://example.com/icon3.png', text: '代驾订单' },
        { icon: 'https://example.com/icon4.png', text: '我的收藏' },
        { icon: 'https://example.com/icon5.png', text: '优惠券' },
        { icon: 'https://example.com/icon6.png', text: '支付记录' },
        { icon: 'https://example.com/icon7.png', text: '地址管理' },
        { icon: 'https://example.com/icon8.png', text: '我的分享' },
        { icon: 'https://example.com/icon9.png', text: '我要投诉' },
        { icon: 'https://example.com/icon10.png', text: '用户协议' },
        { icon: 'https://example.com/icon11.png', text: '联系客服' },
        { icon: 'https://example.com/icon12.png', text: '系统设置' }
      ],

      // 底部 tabbar 数据
      tabbarList: [
        { icon: 'https://example.com/tab1.png', text: '首页', path: '/pages/index/index' },
        { icon: 'https://example.com/tab2.png', text: '技师', path: '/pages/technician/technician' },
        { icon: 'https://example.com/tab3.png', text: '地陪', path: '/pages/guide/guide' },
        { icon: 'https://example.com/tab4.png', text: '代驾', path: '/pages/driver/driver' },
        { icon: 'https://example.com/tab5.png', text: '我的', path: '/pages/my/my' }
      ]
    };
  },
  methods: {
    openVip() {
      // 处理开通 VIP 逻辑，比如跳转支付页面等
      uni.showToast({ title: '前往开通VIP', icon: 'none' });
    },
    handleMenuClick(item) {
      // 处理功能菜单点击逻辑，比如跳转对应页面
      uni.showToast({ title: `点击了${item.text}`, icon: 'none' });
    },
    switchTab(tab) {
      // 切换 tabbar 页面，uniapp 推荐使用 uni.switchTab 跳转 tabbar 页面
      uni.switchTab({
        url: tab.path
      });
    }
  }
};
</script>

<style scoped>
.my-page {
  background: linear-gradient(to bottom, #ff7b9c, #fff);
  min-height: 100vh;
  padding-bottom: 60px; /* 给底部 tabbar 留空间 */
}
.top-bar {
  display: flex;
  align-items: center;
  padding: 20px;
}
.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-right: 10px;
}
.user-info {
  flex: 1;
}
.username {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
}
.user-id {
  font-size: 12px;
  color: #fff;
  margin-top: 2px;
}
.member-tag {
  background-color: #ffd800;
  color: #fff;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}
.msg-icon {
  width: 24px;
  height: 24px;
}
.vip-box {
  background: #fff;
  margin: 0 10px;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.vip-title {
  font-size: 18px;
  font-weight: bold;
  color: #ffb800;
  display: flex;
  align-items: center;
}
.vip-icon {
  color: #ffb800;
  margin-right: 5px;
}
.vip-desc {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}
.open-vip-btn {
  background-color: #ff7b9c;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
}
.menu-list {
  display: flex;
  flex-wrap: wrap;
  padding: 10px;
}
.menu-item {
  width: 25%;
  text-align: center;
  margin-top: 10px;
}
.menu-icon {
  width: 40px;
  height: 40px;
}
.menu-text {
  font-size: 12px;
  color: #333;
  margin-top: 4px;
  display: block;
}
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: #fff;
  display: flex;
  align-items: center;
  border-top: 1px solid #f2f2f2;
}
.tabbar-item {
  flex: 1;
  text-align: center;
}
.tab-icon {
  width: 24px;
  height: 24px;
}
.tab-text {
  font-size: 10px;
  color: #333;
}
</style>